package com.example.controller;

import cn.hutool.json.JSONUtil;
import com.example.annotation.Log;
import com.example.enums.BusinessTypeEnum;
import com.example.service.ISysLogService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("test")
public class TestController {
    @Autowired
    private ISysLogService sysLogService;
 
    @Log(title = "查询列表",businessType = BusinessTypeEnum.OTHER)
    @GetMapping("list1")
    public String list(@RequestParam("id") String id) {

        return JSONUtil.toJsonStr(sysLogService.list());
    }
 
    @Log(title = "添加数据",businessType = BusinessTypeEnum.INSERT)
    @PostMapping("save1")
    public String save() {
        try {
            System.out.println(1/0);
        } catch (Exception e) {
//            throw e;
        }
 
        return "数据添加成功";
    }
 
    @Log(title = "修改数据",businessType = BusinessTypeEnum.UPDATE)
    @PutMapping
    public String update() {
        return "修改数据成功";
    }
 
    @Log(title = "删除数据",businessType = BusinessTypeEnum.DELETE)
    @DeleteMapping
    public String delete() {
        return "删除数据成功";
    }
}